
exports.add=[{
	_type:"controller",
	_config_details: {
		
	},
	_config: {
		name: "NavPath",
		index_view:"index",
		show_index_page: false,
		helpers:[]
	},
	/**
	 * Controller: NavPath.index
	 *		Renders navigation path
	 *
	 * Parameters:
	 *		config.show_index_page typeof Boolean		- Show index page (i.e. /)
	 *		config.current_clickable tpyoef Boolean		- is current page clickable
	 * Returns:
	 *		HTML
	 */
	index: function(config) {
		var t=this;
		this.F("Nav","calc");
		this.configNavPath=config;
		this.nav_path=[];
		var s=this.calc_pages.path.length;
		var checker=(config.current_clickable)?s:s-1;
		for (var i=0;i<s;i++) {
			var p=this.calc_pages.path[i];
			t.nav_path.push({url:p.alias=='/index/'?'/':p.alias,name:p.name,clickable:(i==checker)?false:true});
		}
		config.helpers.forEach(function(a) {
			var arr=a.match(/^(\w+)\.(\w+)$/);
			t.C(arr[1],arr[2],{nav_path:t.nav_path});
		});
		if (config.show_index_page && this.nav_path.length && this.nav_path[0].alias!='/') {
			var p=this.site.models.Page.List("get_by_alias",{alias:"/index/"})[0];
			this.nav_path.unshift({url:'/',name:p.name,clickable:true});
			if (this.nav_path.length>2) this.nav_path[1].clickable=1;
		}
		return this.Cview();
	}
}];

